/*
 * Jamus
 * Copyright (C) 2010 Jamus Team
 *
 * Jamus is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * Jamus is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Jamus.  If not, see <http://www.gnu.org/licenses/>.
 */

/*
 * Plugin.cpp
 *
 *  Created on: Dec 29, 2009
 *      Author: christian moellinger
 */

#include <iostream>

#include "Plugin.h"

using namespace std;

namespace frontend {
namespace test {

log4cxx::LoggerPtr Plugin::logger(log4cxx::Logger::getLogger("frontend.test.Plugin"));

Plugin::Plugin(backend::Plugin& backend) : frontend::Plugin(backend), exit(0)
{
	LOG4CXX_DEBUG(logger, "Create Plugin");
}

Plugin::~Plugin()
{
	LOG4CXX_TRACE(logger, "Destroy Plugin");
}


void Plugin::run()
{
	cout << "loaded testfrontend" << endl;
	cout << "first, we call playpause()..." << endl;
	this->backend.playPause();
	cout << "...and wait 3 seconds, to call it again" << endl;
	sleep(3);
	this->backend.playPause();
	cout << "now, we try getTracklist()..." << endl;
	this->backend.getTrackList();
	cout << "...and start a loop, every 3 secs playPause() is called" << endl;
	while(!this->exit)
	{
		this->backend.playPause();
		sleep(3);
	}
}

void Plugin::cancel()
{
	this->exit=1;
}


} // namespace test
} // namespace frontend

extern "C" frontend::test::Plugin* create(const boost::property_tree::ptree& config, backend::Plugin& backend)
{
	return new frontend::test::Plugin(backend);
}

extern "C" void destroy(frontend::test::Plugin* p)
{
	delete p;
}
